package com.fire.control.system;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.fire.control.system.module.common.controller.BaseController;
import com.fire.control.system.statics.Key;
import com.fire.control.system.support.util.VerifyCodeUtils;
import com.fire.control.system.support.util.XdaoPassword;


@Controller
@RequestMapping
public class IndexController extends BaseController{
	
	@RequestMapping
	public ModelAndView index(){
		return new ModelAndView("index.html");
	}
	
	/*@RequestMapping("index/test")
	public String test(){
		return "/test.html";
	}
	
	@ResponseBody
	@RequestMapping("index/vercode")
	public String ajcDeclareAnnotation(){
		return (String) session.getAttribute(Key.idenCode.toString());
	}*/
	
	@RequestMapping("vercode")
	public void vercode(){
		getResponse().setHeader("Pragma", "No-cache"); 
		getResponse().setHeader("Cache-Control", "no-cache"); 
		getResponse().setDateHeader("Expires", 0); 
		getResponse().setContentType("image/jpeg");
        session.removeAttribute(Key.idenCode.toString());
        try {
        	String verocode = XdaoPassword.getRandomCode();
			session.setAttribute(Key.idenCode.toString(), verocode);
        	VerifyCodeUtils.outputImage(100, 30, getResponse().getOutputStream(), verocode);
		} catch (IOException e) {e.printStackTrace();}
	}
	
	/*@RequestMapping
	public ResponseProtocol index(){
		ResponseJsonProtocol protocol = new ResponseJsonProtocol();
		ResponseMessage.CODE_200.messageToProtocol(protocol).setData("hello Lora !");;
		return protocol;
	}*/
	
}
